All Questions
4 questions
2votes
2answers
1kviews
Migrating legacy code with singletons to Dependency injection
I'm working on a larger, older project. Our code is littered with classical singletons, i.e. classes like public class ABCService { private static final instance = new ABCService(); public ...
2votes
1answer
339views
Using Spring in Java Project
I've got a question about a correct usage of Spring. I know that some people use the DI "aggressively" so that they always use spring and completely eliminate the usage of word "new" in the ...
10votes
2answers
10kviews
Unit testing, factories, and the Law of Demeter
Here's how my code works. I have an object that represents the current state of something akin to a shopping cart order, stored in a 3rd party shopping API. In my controller code, I want to be able to ...
1vote
1answer
127views
Loading data for ShoppingCart item
I'm currently trying to cover our shopping cart with unit tests. Class ShoppingCartItem has property Term. It also loads available terms for this item upon object creation. Currently this is done ...